/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dbs;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author tae
 */
@Entity
@Table(name = "friend")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Friend.findAll", query = "SELECT f FROM Friend f"),
    @NamedQuery(name = "Friend.findByPK", query = "SELECT f FROM Friend f WHERE f.friendPK.userId = :userId AND f.friendPK.friendId = :friendId"),
    @NamedQuery(name = "Friend.findByUserId", query = "SELECT f FROM Friend f WHERE f.friendPK.userId = :userId"),
    @NamedQuery(name = "Friend.findByFriendId", query = "SELECT f FROM Friend f WHERE f.friendPK.friendId = :friendId"),
    @NamedQuery(name = "Friend.findByFollowerFlag", query = "SELECT f FROM Friend f WHERE f.followerFlag = :followerFlag"),
    @NamedQuery(name = "Friend.findByUserIdAndFollwerFlag", query = "SELECT f FROM Friend f WHERE f.friendPK.userId = :userId AND f.followerFlag = :followerFlag"),
    @NamedQuery(name = "Friend.findByFollowingFlag", query = "SELECT f FROM Friend f WHERE f.followingFlag = :followingFlag")})
public class Friend implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected FriendPK friendPK;
    @Column(name = "follower_flag")
    private Short followerFlag;
    @Column(name = "following_flag")
    private Short followingFlag;

    public Friend() {
        this.followerFlag = (short)1;
        this.followingFlag = (short)1;
    }

    public Friend(FriendPK friendPK) {
        this.followerFlag = (short)1;
        this.followingFlag = (short)1;
        this.friendPK = friendPK;
    }

    public Friend(long userId, long friendId) {
        this.followerFlag = (short)1;
        this.followingFlag = (short)1;
        this.friendPK = new FriendPK(userId, friendId);
    }

    public FriendPK getFriendPK() {
        return friendPK;
    }

    public void setFriendPK(FriendPK friendPK) {
        this.friendPK = friendPK;
    }

    public Short getFollowerFlag() {
        return followerFlag;
    }

    public void setFollowerFlag(Short followerFlag) {
        this.followerFlag = followerFlag;
    }

    public Short getFollowingFlag() {
        return followingFlag;
    }

    public void setFollowingFlag(Short followingFlag) {
        this.followingFlag = followingFlag;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (friendPK != null ? friendPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Friend)) {
            return false;
        }
        Friend other = (Friend) object;
        if ((this.friendPK == null && other.friendPK != null) || (this.friendPK != null && !this.friendPK.equals(other.friendPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dbs.Friend[ friendPK=" + friendPK + " ]";
    }
    
}
